from nonebot import on_regex
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import GroupMessageEvent, Bot, Message
from datetime import datetime

# 北京时间监听器
Test_time = on_regex(pattern=r'^beijing_time$', priority=1)
@Test_time.handle()
async def time_detect(bot: Bot, event: GroupMessageEvent, state: T_State):
    # 获取当前北京时间
    current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    # 构建消息
    msg = f"北京时间：{current_time}"
    # 回复消息
    await Test_time.finish(message=Message(msg))